#version 320 es
#ifdef GL_ES
	precision highp float;
#endif
out vec4 FragColor;

in vec3 position;
in float Lx;
in float Rx;

struct Arrow {
	float zStart;
	float zEnd;
	float edgeW;
};
uniform Arrow arrow;

uniform vec4 color;

const float EdgeAlphaIncrementRatio = -0.1;

void main() {
	float t = (arrow.zStart - position.z) / (arrow.zStart - arrow.zEnd);

	float alpha = color.a;
	if (abs(position.x - Lx) < arrow.edgeW || abs(position.x - Rx) < arrow.edgeW)
		alpha += color.a * EdgeAlphaIncrementRatio;

	FragColor = vec4(color.rgb, alpha * (1.0 - t));
}